package com.example.supplychainbackend.controller;

import com.example.supplychainbackend.controller.dto.DataResponse;
import com.example.supplychainbackend.controller.dto.trace.CodeDto;
import com.example.supplychainbackend.controller.dto.trace.CodeRequestDto;
import com.example.supplychainbackend.controller.dto.trace.TraceInfoDto;
import com.example.supplychainbackend.service.ProductionService;
import com.example.supplychainbackend.service.TraceService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("api/trace")
@AllArgsConstructor
public class TraceController {
    private final TraceService traceService;
    //溯源信息查询
    @GetMapping("/traceInfo/{id}")
    public DataResponse<TraceInfoDto> getInfo(@PathVariable String id) {
        TraceInfoDto res = traceService.getTraceInfo(id);
        return DataResponse.success(res);
    }

//    @GetMapping("/traceCode/list")
//    public DataResponse<List<CodeDto>> listTraceCodes() {
//        TraceInfoDto res = traceService.getTraceInfo(id);
//        return DataResponse.success(res);
//    }

    @GetMapping("/traceCode/{bn}")
    public DataResponse<CodeDto> getCode(@PathVariable String bn) {
        return DataResponse.success(traceService.getCodeByBatch(bn));
    }
}
